<?php
session_start();
if(!isset($_SESSION['username'])){
	header("location:../index.php");
}
?>

<link href="../css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
<link href="../css/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="../css/table.css" rel="stylesheet" type="text/css" />

<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="../js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="../js/jquery-ui.min.js" type="text/javascript"></script>

<script>	
$(document).ready(function() {
	$("#formID").validationEngine();
});
</script>

<?php
include "../inc/db.php";

if($set == "1"){
$result = mysql_query("select * from tb_site group by kota asc;");
}else{
$sql="SELECT DATE_ADD(now(),INTERVAL (select * from tb_expired) DAY), now();";
$hasil=mysql_query($sql);
$kolom=mysql_fetch_array($hasil);

$sql="select * from tb_site where tgl_habis_kontrak between '$kolom[1]' and '$kolom[0]' group by kota asc";

$result = mysql_query($sql);
}
$kota=malang;
?>

<h2>SITE REPORT</h2>
<form action="cetak_report.php?set=<?php echo $_GET['mod']?>" method="post" target="_blank" id="formID">
Search By Kota 
	<select name="kota" id="kota" class="validate[required]">
      	<option value="">-- Pilih Kota -</option>
        <?php
		if($_GET['mod'] == "reportall"){
		?>
        <option value="All">All</option>
        <?php
		}
		?>
        <option value="Bangkalan" <?php if($kolom[5] == "Bangkalan"){ echo "selected='selected'"; } ?>>Bangkalan</option>
        <option value="Banyuwangi" <?php if($kolom[5] == "Banyuwangi"){ echo "selected='selected'"; } ?>>Banyuwangi</option>
        <option value="Blitar" <?php if($kolom[5] == "Blitar"){ echo "selected='selected'"; } ?>>Blitar</option>
        <option value="Bojonegoro" <?php if($kolom[5] == "Bojonegoro"){ echo "selected='selected'"; } ?>>Bojonegoro</option>
        <option value="Bondowoso" <?php if($kolom[5] == "Bondowoso"){ echo "selected='selected'"; } ?>>Bondowoso</option>
        <option value="Gresik" <?php if($kolom[5] == "Gresik"){ echo "selected='selected'"; } ?>>Gresik</option>
        <option value="Jember" <?php if($kolom[5] == "Jember"){ echo "selected='selected'"; } ?>>Jember</option>
        <option value="Jombang" <?php if($kolom[5] == "Jombang"){ echo "selected='selected'"; } ?>>Jombang</option>
        <option value="Kediri" <?php if($kolom[5] == "Kediri"){ echo "selected='selected'"; } ?>>Kediri</option>
        <option value="Lamongan" <?php if($kolom[5] == "Lamongan"){ echo "selected='selected'"; } ?>>Lamongan</option>
        <option value="Lumajang" <?php if($kolom[5] == "Lumajang"){ echo "selected='selected'"; } ?>>Lumajang</option>
        <option value="Madiun" <?php if($kolom[5] == "Madiun"){ echo "selected='selected'"; } ?>>Madiun</option>
        <option value="Magetan" <?php if($kolom[5] == "Magetan"){ echo "selected='selected'"; } ?>>Magetan</option>
        <option value="Malang" <?php if($kolom[5] == "Malang"){ echo "selected='selected'"; } ?>>Malang</option>
        <option value="Mojokerto" <?php if($kolom[5] == "Mojokerto"){ echo "selected='selected'"; } ?>>Mojokerto</option>
        <option value="Nganjuk" <?php if($kolom[5] == "Nganjuk"){ echo "selected='selected'"; } ?>>Nganjuk</option>
        <option value="Ngawi" <?php if($kolom[5] == "Ngawi"){ echo "selected='selected'"; } ?>>Ngawi</option>
        <option value="Pacitan" <?php if($kolom[5] == "Pacitan"){ echo "selected='selected'"; } ?>>Pacitan</option>
        <option value="Pamekasan" <?php if($kolom[5] == "Pamekasan"){ echo "selected='selected'"; } ?>>Pamekasan</option>
        <option value="Pasuruan" <?php if($kolom[5] == "Pasuruan"){ echo "selected='selected'"; } ?>>Pasuruan</option>
        <option value="Ponorogo" <?php if($kolom[5] == "Ponorogo"){ echo "selected='selected'"; } ?>>Ponorogo</option>
        <option value="Probolinggo" <?php if($kolom[5] == "Probolinggo"){ echo "selected='selected'"; } ?>>Probolinggo</option>
        <option value="Sampang" <?php if($kolom[5] == "Sampang"){ echo "selected='selected'"; } ?>>Sampang</option>
        <option value="Sidoarjo" <?php if($kolom[5] == "Sidoarjo"){ echo "selected='selected'"; } ?>>Sidoarjo</option>
        <option value="Situbondo" <?php if($kolom[5] == "Situbondo"){ echo "selected='selected'"; } ?>>Situbondo</option>
        <option value="Sumenep" <?php if($kolom[5] == "Sumenep"){ echo "selected='selected'"; } ?>>Sumenep</option>
        <option value="Surabaya" <?php if($kolom[5] == "Surabaya"){ echo "selected='selected'"; } ?>>Surabaya</option>
        <option value="Trenggalek" <?php if($kolom[5] == "Trenggalek"){ echo "selected='selected'"; } ?>>Trenggalek</option>
        <option value="Tuban" <?php if($kolom[5] == "Tuban"){ echo "selected='selected'"; } ?>>Tuban</option>
        <option value="Tulungagung" <?php if($kolom[5] == "Tulungagung"){ echo "selected='selected'"; } ?>>Tulungagung</option>
    </select>
<input type="submit" name="button" id="button" value="Cetak">
</form>
<br>
<br>
<br>
<table width="650" class="bordered">
  <tr>
    <td width="60">Nama Site </td>
    <td width="67">Tanggal Kontrak</td>
    <td width="100">Tanggal Habis Kontrak</td>
    <td width="64">Lokasi Site</td>
    <td width="52">Kota</td>
    <td width="89">Keterangan 1</td>
    <td width="73">Keterangan 2</td>
  </tr>
  <?php
  while($kolom=mysql_fetch_array($result)){
  ?>
  <tr>
    <td><?php echo $kolom[1]; ?></td>
    <td><?php echo $kolom[2]; ?></td>
    <td><?php echo $kolom[3]; ?></td>
    <td><?php echo $kolom[4]; ?></td>
    <td><?php echo $kolom[5]; ?></td>
    <td><?php echo $kolom[6]; ?></td>
    <td><?php echo $kolom[7]; ?></td>
  </tr>
  <?php
  }
  ?>
</table>
